package com.morningstar.gateway.resolver;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

import java.util.Objects;

/**
 * @author yls
 */
//@Component("keyResolverUser")
public class KeyResolverUser implements KeyResolver {
    /**
     *
     */
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public Mono<String> resolve(ServerWebExchange exchange) {
       return Mono.just(Objects.requireNonNull(exchange.getRequest().getQueryParams().getFirst("user")));
    }
}
